@extends('oms-backend::layouts.default')

@section ('title','上传文件列表')

@section('breadcrumbs')

    <h2>上传文件列表</h2>
    <ol class="breadcrumb">
        <li><a href="{!!route('admin.store.index')!!}"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li class="active">上传文件列表</li>
    </ol>

@endsection

@section('content')

    <div class="tabs-container">
        <ul class="nav nav-tabs">
            <li class="{{ Active::query('type','Order') }}"><a href="{{route('admin.oms.file.upload',['type'=>'Order'])}}">订单信息
                    </a></li>
            <li class="{{ Active::query('type','OrderCancel') }}"><a href="{{route('admin.oms.file.upload',['type'=>'OrderCancel'])}}"> 订单取消信息
                    </a></li>
            <li class="{{ Active::query('type','OrderReturn') }}"><a href="{{route('admin.oms.file.upload',['type'=>'OrderReturn'])}}"> 订单退货信息
                </a></li>
        </ul>
        <div class="tab-content">
            <div id="tab-1" class="tab-pane active">
                <div class="panel-body">
                    <div class="row">
                        {!! Form::open( [ 'route' => ['admin.oms.file.upload'], 'method' => 'get', 'id' => 'base-form','class'=>'form-horizontal'] ) !!}
                        <input type="hidden" name="type" value="{{request('type')?request('type'):''}}">
                        <div class="col-md-3">
                            <select class="form-control" name="status">
                                <option>请选择文件状态</option>
                                <option value="1">上传成功</option>
                                <option value="2">上传失败</option>
                            </select>
                        </div>
                        <div class="col-md-4">
                            <button type="submit" class="btn btn-primary">查找</button>
                        </div>
                        {!! Form::close() !!}
                    </div>
                    <div class="hr-line-dashed"></div>

                    <div class="box-body table-responsive">
                        <table class="table table-hover table-bordered">
                            <tbody>
                            <!--tr-th start-->
                            <tr>
                                <th>文件路径</th>
                                <th>FTP文件</th>
                                <th>备注</th>
                                <th>最后同步数据记录</th>
                                <th>上传状态</th>
                                <th>上传时间</th>
                                <th>操作</th>
                            </tr>
                            <!--tr-th end-->

                            @foreach ($files as $item)
                                <tr>
                                    <td><a href="{{$item->path}}">{{$item->path}}</a></td>
                                    <td>{{$item->remote}}</td>
                                    <td>{{$item->message}}</td>
                                    <td>{{$item->last_tag}}</td>
                                    <td>{{$item->status==1?'成功':'失败'}}</td>
                                    <td>{{$item->created_at}}</td>
                                    <td>
                                        <a class="btn btn-xs btn-danger del-attr" href="javascript:;"
                                           data-href="{{route('admin.oms.file.deleteUploadFile',['id' =>$item->id])}}">
                                            <i data-toggle="tooltip" data-placement="top"
                                               class="fa fa-trash"
                                               title="删除"></i></a>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                            <tfoot>
                            <tr>
                                <td colspan="7" class="footable-visible">
                                    {!! $files->render() !!}
                                </td>
                            </tr>
                            </tfoot>
                        </table>
                    </div><!-- /.box-body -->
                </div>
            </div>
        </div>
    </div>

@endsection

@section('after-scripts-end')
    <script>
        $(function () {
            $('.del-attr').on('click', function () {
                var obj = $(this);
                swal({
                    title: "确定删除该文件记录吗?",
                    text: "删除记录有可能会影响数据重复同步",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "删除",
                    closeOnConfirm: false
                }, function () {
                    var url = obj.data('href') + "?_token=" + $('meta[name="_token"]').attr('content');

                    $.post(url, function (ret) {
                        if(ret.status){
                            swal({
                                title: "删除成功！",
                                text: "",
                                type: "success"
                            }, function () {
                                location.reload();
                            });
                        }else{
                           // swal("该参数下存在商品,不能删除!", "", "warning");
                        }
                    });

                });

            });
        });
    </script>
@stop